home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
ada
/
gwuada_9.zip
/
GLIB.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-27
|
16KB
|
558 lines
/*
* Copyright (C) 1985-1992 New York University
*
* This file is part of the Ada/Ed-C system. See the Ada/Ed README file for
* warranty (none) and distribution info and also the GNU General Public
* License for more details.
*/
/* glib.c: translation of lib.stl for code generator */
#define GEN
#include "hdr.h"
#include "libhdr.h"
#include "vars.h"
#include "segment.h"
#include "gvars.h"
#include "ops.h"
#include "type.h"
#include "ifile.h"
#include "segmentp.h"
#include "gutilp.h"
#include "setp.h"
#include "axqrp.h"
#include "libp.h"
#include "libfp.h"
#include "miscp.h"
#include "glibp.h"
static Set remove_dependent(int);
extern int ADA_MIN_INTEGER, ADA_MAX_INTEGER;
extern long ADA_MIN_FIXED, ADA_MAX_FIXED;
extern Tuple segment_map_new(), segment_map_put();
extern Segment segment_new();
extern Segment CODE_SEGMENT, DATA_SEGMENT, DATA_SEGMENT_MAIN;
/*
* Librarian and binder
*
* bind renamed binder to avoid conflict with c library routine of same name
*/
Segment main_data_segment() /*;main_data_segment*/
{
/* Initialize the main data segment needed for all programs. This consists
* mainly of the type templates for the standard types. As the templates
* are defined, the segment offset of the associated symbols is set
* correctly. In the SETL version index 81 is the first free position
* after templates are allocated and is used as the value of the macro
* relay_tables in the interpreter. We improve on this by setting the first
* word in the segment to contain the offset of the start of the relay
* sets.
*/
/* Template pointers */
struct tt_i_range *tt_for_integer;
struct tt_e_range *boolean_tt;
struct tt_i_range *positive_tt;
struct tt_array *string_tt;
struct tt_i_range *null_index_tt;
struct tt_s_array *null_string_tt;
struct tt_e_range *character_tt;
struct tt_task *main_task_type_tt;
struct tt_i_range *natural_tt;
struct tt_fx_range *duration_tt;
struct tt_fx_range *integer_fixed_tt;
struct tt_fl_range *float_tt;
int *ds, di, i, off_for_main_task_body;
Segment seg;
/* SETL text used to define initial data segment:
* DATA_SEGMENT =
* [tt_access, 2] 1 : $ACCESS
* + [tt_i_range, 1, -(2**30)+1, 2**30-1] 3 : integer
* + [tt_enum, 1, 0, 1, 7 : boolean
* 5, 70, 65, 76, 83, 69,
* 4, 84, 82, 85, 69]
* + [tt_i_range, 1, 1, 2**30-1] 22 : positive
* + [tt_u_array, 2**30-1, 1, 1, 23, 1, 22] 26 : string
* + [tt_i_range, 1, 1, 0] 33 : null index
* + [tt_s_array, 0, 1, 2, 1, 0] 37 : null string
* + [tt_enum, 1, 0, 127] 43 : character
* + [tt_task, 1, 6, 1, 54, 0, 0] 47 : main_task_type
* + [main_cs, 0, 0] 54 : main_task_body
* + [tt_i_range, 1, 0, 2**30-1] 57 : natural
* + [tt_fixed, 1, -3, -3, -(2**30)+1,
* 2**30-1] 61 : duration
* + [tt_fixed, 1, 0, 0, -(2**30)+1, 2**30-1] 67 : integer_fixed
* + [tt_f_range, 1, F_TO_I(ada_min_real),
* F_TO_I(ada_max_real)] 73 : FLOAT
* + [tt_i_range, 1, -(2**15)+1, 2**15-1] 77 : SHORT_INTEGER
* 81 : relay sets
* [tt_access, 2] : $ACCESS
*/
ds = (int *) ecalloct(150, sizeof(int), "main-data-segment");
/* di[0] used to store offset of relay tables(see below) */
di = 1; /* initial offset */
S_OFFSET(symbol_daccess) = di;
/* first two words are not template */
ds[di++] = TT_ACCESS;
ds[di++] = 2;
/* tt_i_range, 1, -(2**30)+1, 2**30-1] : integer */
S_OFFSET(symbol_integer) = di;
S_OFFSET(symbol_universal_integer) = di;
tt_for_integer = I_RANGE((ds + di));
tt_for_integer->ttype = TT_I_RANGE;
tt_for_integer->object_size = 1;
tt_for_integer->ilow = ADA_MIN_INTEGER;/* check this and next line */
tt_for_integer->ihigh = ADA_MAX_INTEGER;
S_OFFSET(symbol_integer) = di;
di += WORDS_I_RANGE;
/* [tt_enum, 1, 0, 1, : boolean * 5, 70, 65, 76, 83, 69, *
4, 84, 82, 85, 69] */
S_OFFSET(symbol_boolean) = di;
boolean_tt = E_RANGE((ds + di));
boolean_tt->ttype = TT_ENUM;
boolean_tt->object_size = 1;
boolean_tt->elow = 0;
boolean_tt->ehigh = 1;
di += WORDS_E_RANGE;
/* put enumeration values */
ds[di++] = 5; /* length of FALSE */
ds[di++] = 'F';
ds[di++] = 'A';
ds[di++] = 'L';
ds[di++] = 'S';
ds[di++] = 'E';
ds[di++] = 4; /* length of TRUE */
ds[di++] = 'T';
ds[di++] = 'R';
ds[di++] = 'U';
ds[di++] = 'E';
/* [tt_i_range, 1, 1, 2**30-1] : positive */
S_OFFSET(symbol_positive) = di;
positive_tt = I_RANGE((ds + di));
positive_tt->ttype = TT_I_RANGE;
positive_tt->object_size = 1;
positive_tt->ilow = 1;
positive_tt->ihigh = ADA_MAX_INTEGER;/* check this */
di += WORDS_I_RANGE;
/* [tt_u_array, 2**30-1, 1, 1, 23, 1, 22] : string */
S_OFFSET(symbol_string_type) = di;
S_OFFSET(symbol_string) = di;
string_tt = ARRAY((di + ds));
string_tt->ttype = TT_U_ARRAY;
string_tt->object_size = ADA_MAX_INTEGER;
string_tt->dim = 1;
string_tt->component_base = 1;
/* string_tt->component_offset is set below when character defined */
string_tt->index1_base = 1;
string_tt->index1_offset = S_OFFSET(symbol_positive);
di += WORDS_ARRAY;
/* [tt_i_range, 1, 1, 0] : null index */
null_index_tt = I_RANGE((ds + di));
null_index_tt->ttype = TT_I_RANGE;
null_index_tt->object_size = 1;
null_index_tt->ilow = 1;
null_index_tt->ihigh = 0;
di += WORDS_I_RANGE;
/* [tt_s_array, 0, 1, 2, 1, 0] : null string */
null_string_tt = S_ARRAY((di + ds));
null_string_tt->ttype = TT_S_ARRAY;
null_string_tt->object_size = 0;
;
null_string_tt->component_size = 1;
null_string_tt->index_size = 2;
null_string_tt->salow = 1;
null_string_tt->sahigh = 0;
di += WORDS_S_ARRAY;
/* [tt_enum, 1, 0, 127] : character */
S_OFFSET(symbol_character) = di;
S_OFFSET(symbol_character_type) = di;
/* Can set component_offset for string now */
string_tt->component_offset = di;
character_tt = E_RANGE((di + ds));
character_tt->ttype = TT_ENUM;
character_tt->object_size = 1;
;
character_tt->elow = 0;
character_tt->ehigh = 127;
di += WORDS_E_RANGE;
ds[di++] = -1; /* no list of images */
/* [tt_task, 1, 6, 1, 54, 0, 0] : main_task_type */
S_OFFSET(symbol_main_task_type) = di;
main_task_type_tt = TASK((di + ds));
main_task_type_tt->ttype = TT_TASK;
main_task_type_tt->object_size = 1;
main_task_type_tt->priority = MAX_PRIO-1; /* TBSL: priority of main */
main_task_type_tt->body_base = 1;/* segment number */
/* body_off filled in later */
main_task_type_tt->collection_size = 1000;
main_task_type_tt->collection_avail = 1000;
main_task_type_tt->nb_entries = 0;
main_task_type_tt->nb_families = 0;
#ifdef MONITOR
#define NAMESIZE 119
{
FILE *fp;
char source_file[NAMESIZE];
int length;
strcpy( main_task_type_tt->task_name, "main");
fp = fopen( "CWKLIB.$$$", "r" );
if ( fp == NULL )
{
fprintf(stderr, "Cannot open CWKLIB\n");
}
fgets( source_file, NAMESIZE, fp );
length = strlen(source_file) - 1;
source_file[length] = '\0';
strcpy(main_task_type_tt->task_file, source_file);
}
#undef NAMESIZE
#endif
di += WORDS_TASK;
/* [main_cs, 0, 0] : main_task_body */
off_for_main_task_body = di;
ds[di++] = MAIN_CS;
ds[di++] = 0;
ds[di++] = 0;
main_task_type_tt->body_off = off_for_main_task_body;
/* [tt_i_range, 1, 0, 2**30-1] : natural */
S_OFFSET(symbol_natural) = di;
natural_tt = I_RANGE((ds + di));
natural_tt->ttype = TT_I_RANGE;
natural_tt->object_size = 1;
;
natural_tt->ilow = 0;
natural_tt->ihigh = ADA_MAX_INTEGER;/* check this */
di += WORDS_I_RANGE;
/* [tt_fixed, 1, -3, -3, -(2**30)+1, 2**30-1] : duration */
S_OFFSET(symbol_duration) = di;
duration_tt = FX_RANGE((ds + di));
duration_tt->ttype = TT_FX_RANGE;
duration_tt->object_size = 1;
duration_tt->small_exp_2 = -3;
duration_tt->small_exp_5 = -3;
duration_tt->fxlow = 0 ;
du